<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Users_model extends CI_Model {

    private $tbl_users = 'users';

    public function __construct() {
        parent::__construct();
    }

    function validate() {
        $this->db->where('user_login', $this->input->post('username'));
        $this->db->where('user_pass', md5($this->input->post('password')));
        $query = $this->db->get($this->tbl_users);

        if ($query->num_rows == 1) {
            return true;
        }
    }

    function is_logged_in() {
        $is_logged_in = $this->session->userdata('is_logged_in');
        if (!isset($is_logged_in) || $is_logged_in != true) {
            echo 'You don\'t have permission to access this page. <a href="/users">Login</a>';
            die();
            //$this->load->view('login_form');
        }
    }

}